/** CSC 460/560 Real Time Operating Systems - Mantis Cheng
 *	Fall 2007
 *	
 *	@author Scott Craig
 *
 *	A driver for sending debugging messages from one radio
 *	to another. Delivery is not guaranteed.
 *
 *  NB!: Must be compiled with optimisation at least -O2
 */

#include "radio.h"
#include <util/delay.h>

#define LED_D5_GREEN	0x40

/**
 *  Write some strings to the radio/UART
 */
int bimp_main()
{
    int i, count;

    /** Disable default prescaler to make processor speed 8 MHz. */
    CLKPR = (1<<CLKPCE);
    CLKPR = 0x00;

    radio_init((uint8_t) 110, 0xABBA, 0);

    // Init an LED on the key
    PORTD &= ~LED_D5_GREEN;
    DDRD |= LED_D5_GREEN;

    for(count = 0; ; ++count)
    {
        //radio_print("Testing\r\n");
        //radio_print("Testing: packet %d\r\n", count);
        //radio_print("TestingTestingTestingTestingTestingTesting\r\n");
        radio_print("Testing radio to UART printing: string number %d\r\n", count);

        radio_print(
            "A23456789012345678901234567890\r\n"
            "B23456789012345678901234567890\r\n"
            "C23456789012345678901234567890\r\n"
        );

        PORTD ^= LED_D5_GREEN;

        for(i=0; i < 25; ++i) _delay_ms(40);
    }

    return 0;
}

